package com.sftpserver;

import com.dto.config.IniDTO;
import com.utils.SftpServerUtils;
import com.sftpserver.service.SftpServerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Configurable;

import static com.fx.notify.NotifyTest.doNotify;


@Slf4j(topic = "服务启动类")
@Configurable
public class RunServer {

    public static SftpServerService serverBean;



    public RunServer() {

        try {
            serverBean = SftpServerUtils.setupSftpServer(IniDTO.getSftp_username(), IniDTO.getSftp_password(), IniDTO.getSftp_host(), Integer.parseInt(IniDTO.getSftp_port()), IniDTO.getSftp_path());

            log.info("--------- SFTP服务已启动 ----------");
            doNotify("","SFTP服务已启动","dialog-information.png");
        } catch (Throwable throwable) {
            log.error("-------- SFTP服务启动失败 --------"+throwable);
            doNotify("","SFTP服务启动失败","dialog-warning.png");
        }

    }
}
